package com.xf.common.core.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description
 * @Author FengYi
 * @Date 2020-06-09 9:51
 */
@Data
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 771836922595187944L;


    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(type = IdType.AUTO)
    private long id;


    private String remark;


    @TableField(fill = FieldFill.INSERT)
    private String createdBy;


    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    private Date createdDate;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updatedBy;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    private Date updatedDate;

    @Version

    @TableField(fill = FieldFill.INSERT)
    private Long dataVersion;


    @TableField(fill = FieldFill.INSERT)
    private Long concurrentVersion;

    /**
     * 数据是否有效，0:正常，1:删除
     */
    @TableLogic(value = "0",delval = "1") //value表示逻辑未删除值，delval表示逻辑删除设置的值

    @TableField(value = "`status`", fill = FieldFill.INSERT)
    private Integer status;

}
